import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd

# 加载数据
file_path = 'F:/projdvn/car_prices_encoded_scaled_outliers.csv'
df = pd.read_csv(file_path)

# 选择特征变量，排除目标变量之外的列
corr_df = df.drop(['Unnamed: 0'], axis=1)

# 计算相关系数矩阵
corr = corr_df.corr()

# 创建画布
plt.figure(figsize=(12, 10))

# 设置负号和中文字体
plt.rcParams['axes.unicode_minus'] = False
plt.rcParams['font.sans-serif'] = ['WenQuanYi Zen Hei']

# 绘制热力图
sns.heatmap(corr, annot=True, cmap='coolwarm', linewidths=0.5)

# 添加图标题
plt.title('汽车各变量热力图')

# 显示图形
plt.show()